package com.knowif.backend.dto;

import com.knowif.pojo.Offer;
import com.knowif.pojo.StanderSorce;
import com.knowif.pojo.TUser;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Data
public class OfferDto {
    private Offer offer;
    private List<Offer> offers;
    private StanderSorce standerSorce;
    private TUser tUser;

    public static void andTUser(List<OfferDto> offerDtos, List<TUser> tUsers) {
        if(!CollectionUtils.isEmpty(offerDtos) && !CollectionUtils.isEmpty(tUsers)){
            offerDtos.forEach(offerDto -> {
                tUsers.forEach(tu -> {
                    if(tu.getId().equals(offerDto.getOffer().getUserId())){
                        offerDto.setTUser(tu);
                    }
                });
            });
        }
    }

    public static void andStanderSorces(List<OfferDto> offerDtos, List<StanderSorce> standerSorces) {
        if(!CollectionUtils.isEmpty(offerDtos) && !CollectionUtils.isEmpty(standerSorces)) {
            offerDtos.forEach(offerDto -> {
                standerSorces.forEach(ss -> {
                    if(ss.getId().equals(offerDto.getOffer().getStanderScoreId())){
                        offerDto.setStanderSorce(ss);
                    }
                });
            });
        }
    }
}
